package com.luoran.bartalks.service.impl;

import java.util.List;

import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.luoran.bartalks.dao.IBtContainerDao;
import com.luoran.bartalks.entity.BaseInfo;
import com.luoran.bartalks.entity.biz.BtContainer;
import com.luoran.bartalks.service.IBtContainerService;

@Service
public class BtContainerService implements IBtContainerService {

	@Autowired
	private IBtContainerDao dao;

	@Override
	public PageQuery<? extends BaseInfo> getQueryList(PageQuery<? extends BaseInfo> pageQuery) {
		dao.queryPage(pageQuery);
		return pageQuery;
	}

	@Override
	public BtContainer getContainerByCode(String containerCode, String companyId) {
		return dao.getContainerByCode(containerCode, companyId);
	}

	@Override
	public BtContainer addContainer(BtContainer container) {
		dao.insertTemplate(container);
		return container;
	}

	@Override
	public BtContainer getContainerById(String id) {
		return dao.single(id);
	}

	@Override
	public void updateContainer(BtContainer container) {
		dao.updateById(container);
	}

	@Override
	public void deleteContainer(String id) {
		dao.deleteById(id);
	}

	// 扫描容器时,需要根据容器ID和当前操作人所属公司ID,校验容器.
	@Override
	public BtContainer getContainerByIdAndCompanyId(String resourceId, String companyId) {

		return dao.getContainerByIdAndCompanyId(resourceId, companyId);
	}

	@Override
	public List<BtContainer> getContainerBycompanyId(String companyId) {
		return dao.getContainerBycompanyId(companyId);
	}

	@Override
	public List<String> getContainerQrcodeBycompanyId(String companyId) {
		return dao.getContainerQrcodeBycompanyId(companyId);
	}

	@Override
	public BtContainer getContainerByQrcodeAndCompanyId(String qrcode, String companyId) {
		return dao.getContainerByQrcodeAndCompanyId(qrcode, companyId);
	}


}
